package com.oscarmovie.action;

import java.util.List;

import com.opensymphony.xwork2.ActionSupport;
import com.oscarmovie.Constants;
import com.oscarmovie.model.Country;
import com.oscarmovie.service.CountryService;

public class CountryAction extends ActionSupport {

	private static final long serialVersionUID = 1L;

	private CountryService countryService;
	
	private Country country;
	private List<Country> countries;

	
	public String add() throws Exception {
		setCountry(null);
		return Constants.ADD;
	}
	public String edit() throws Exception {
		loadAll();
		load();
		return Constants.EDIT;
	}
	public String save() throws Exception {
		countryService.save(country);
		return edit();
	}

	public String load() throws Exception {
		setCountry(countryService.load(country.getId()));
		return SUCCESS;
	}

	public String loadAll() throws Exception {
		this.countries = countryService.loadAll();
		return SUCCESS;
	}


	public List<Country> getCountries() {
		return countries;
	}

	public void setCountryService(CountryService countryService) {
		this.countryService = countryService;
	}

	public void setCountry(Country country) {
		this.country = country;
	}

	public Country getCountry() {
		return country;
	}


}
